package com.yunban.project.template.controller;

import com.yunban.project.template.model.dto.SavePreviewReq;
import com.yunban.project.template.service.PreviewRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: lijiajun
 * @date: 2025-03-26
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "预览记录模块")
@RequestMapping("/preview-api")
public class PreviewRecordController {

    @Resource
    private PreviewRecordService previewRecordService;

    @PostMapping("/info")
    @Operation(summary = "保存预览记录")
    public String savePreview(@RequestBody @Validated SavePreviewReq req) {
        return previewRecordService.savePreview(req);
    }

    @NoNeedLogin
    @GetMapping("/html")
    @Operation(summary = "查看预览html")
    public String getPreviewHtml(@RequestParam("previewId") String previewId) {
        return previewRecordService.getPreviewHtml(previewId);
    }
}
